import java.util.Scanner;


class Login{
    private final String name="linjunjie";

    private final String id="88888888";

    public void loginin(String name,String id)throws Namerror,Iderror{
        if (!this.name.equals(name)){
            throw new Namerror("用户名错误！");
        }
        if (!this.id.equals(id)){
            throw new Iderror("密码错误！");
        }else {
            System.out.println("登录成功！");
        }
    }

}


public class Main {

    public static void main(String[] args) {
        Scanner scanner=new Scanner(System.in);
        System.out.println("请输入用户名：");
        String name=scanner.nextLine();
        System.out.println("请输入密码：");
        String id= scanner.nextLine();

        Login login=new Login();
        try {
            login.loginin(name,id);
        }catch (Namerror e){
            e.printStackTrace();
            System.out.println("Username Exception");
        }catch (Iderror e){
            e.printStackTrace();
            System.out.println("Id Exception");
        }

    }









    public static boolean iszm(char ch){
        if(ch!=' ')
            return true;
        return false;
    }

    public static int countSegments2(String s) {
        int count=0;

        if (iszm(s.charAt(0))){
            count++;
        }

        for(int j=0;j<s.length();j++){

            if(j>0&&s.charAt(j-1)==' '&&iszm(s.charAt(j)))
                count++;
        }
        return count;
    }

    public static int countSegments1(String s) {
        int count=0;
        for(int i=0;i<s.length();i++){
            char ch=s.charAt(i);
            if(!iszm(ch))
                continue;
            else{
                count++;
                while(iszm(ch)&&i<s.length()){
                    i++;
                    if (i<s.length()){
                        ch=s.charAt(i);
                    }
                }
            }
        }
        return count;
    }

    public static int countSegments(String s) {
        int count=0;

        s.trim();

        for(int j=0;j<s.length();j++){

            if((j==0||s.charAt(j-1)==' ')&&s.charAt(j)!=' ')
                count++;
        }
        return count;
    }

    public static void main4(String[] args) {
        System.out.println(countSegments("             "));
        //"Hello, my name is John"
        //", , , ,        a, eaefa"
    }


    public static void main3(String[] args) {
        Scanner scanner=new Scanner(System.in);

        String string=scanner.nextLine();

        String string1=string.replace("嘉","鸡");//字符串替换

        String[] string2=string.split("&");//分割字符串

        char[] chars={'h','j','豪'};

        String string3=new String(chars);

        System.out.println(string3);

        for (String s : string2) {
            System.out.println(s);
        }

//        char ch=string.charAt(2);

        System.out.println(string1);
    }



    public static void main2(String[] args) {
        Scanner scanner=new Scanner(System.in);

        String string="hello world";

        String string1=scanner.nextLine();

        String string2=string1.trim();//去除字符串开头和结尾的空格

        System.out.println(string2);

        System.out.println(string.contains(string2));//字符串中是否包含某个子字符串
    }






    public static void main1(String[] args) {
        // 创建两个内容相同的字符串对象
        String str1 = new String("hello");
        String str2 = "hello";

        // 使用 intern 方法
        String internedStr1 = str1.intern();

        // 比较引用
        System.out.println(str1 == str2); // 输出 false，因为 str1 和 str2 指向不同的对象
        System.out.println(internedStr1 == str2); // 输出 true，因为 internedStr1 和 str2 都指向常量池中的 "hello"
    }



/*
    public static boolean isAdmin(String userId){
        return userId.toLowerCase()=="admin";
    }
    public static void main(String[] args){
        System.out.println(isAdmin("Admin"));
    }*/



    /*String str = new String("good");

    char[ ] ch = { 'a' , 'b' , 'c' };

    public static void main(String[] args){
        Main ex = new Main();
        ex.change(ex.str,ex.ch);
        System.out.print(ex.str + " and ");
        System.out.print(ex.ch);
    }
    public void change(String str, char[] ch){
        str = "test ok";
        ch[0] = 'g';
    }*/
}